//
//  NSMutableArray+Extension.m
//  JCTool
//
//  Created by chun on 2018/5/12.
//  Copyright © 2018年 gome. All rights reserved.
//

#import "NSMutableArray+Extension.h"
#import "NSObject+Extension.h"

@implementation NSMutableArray (Extension)
/// 空数组
- (BOOL)jc_isEmpty {
    if ([self jc_isEmptyObject] || self.count == 0) {
        return YES;
    } else {
        return NO;
    }
}

///插入一个元素
- (void)jc_insertObjcet:(nonnull id)object atIndex:(NSInteger)index  {
    
    if (index >= self.count) {
        return;
    }
    
    if (object == nil || [object isKindOfClass:[NSNull class]]) {
        return;
    }
    
    [self insertObject:object atIndex:index];
}

///添加一个对象
- (void)jc_addObject:(nonnull id)object {
    
    if (object == nil || [object isKindOfClass:[NSNull class]]) {
        return;
    }
    
    [self addObject:object];
}

///添加多个对象
- (void)jc_addObjectsFromArray:(NSArray *)array {
    
    if (array == nil ||
        [array isKindOfClass:[NSNull class]] ||
        ![array isKindOfClass:[NSArray class]]) {
        return;
    }
    
    [self addObjectsFromArray:array];
}
@end
